package com.atguigu.yygh.hosp.controller;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.DepartmentService;
import com.atguigu.yygh.vo.hosp.DepartmentVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "科室管理")
@RestController
@RequestMapping("/admin/hosp/department")
//@CrossOrigin
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    //根据医院编号查询所有科室
    @ApiOperation(value = "根据医院编号查询所有科室")
    @GetMapping("getDeptList/{hoscode}")
    public Result getDeptList(@PathVariable String hoscode){
        //泛型用Department不行，因为大科室下面还有小科室
        //depcode/name是子科室的，bigcode/name是上级大科室的
        List<DepartmentVo> list = departmentService.findDeptTree(hoscode);   //返回的是大科室-小科室的一个树形结构
        return Result.ok(list);
    }
}
